package cn.com.fattiger.framework.remoting.netty4.client.handle;


import io.netty.channel.Channel;

import java.util.List;

import cn.com.fattiger.framework.remoting.netty4.client.ResponseFuture;
import cn.com.fattiger.framework.remoting.netty4.common.Invocation;
import cn.com.fattiger.framework.remoting.netty4.common.protocol.handle.AbstractReceivedHandle;

public class ClientReceivedHandle extends AbstractReceivedHandle<Channel> {

	@SuppressWarnings("unchecked")
	@Override
	public void receivedObject(Channel channel, Object obj) {
		// TODO Auto-generated method stub
		
		System.out.println("recv:" + obj);
		if (obj instanceof List) {
			List<Invocation> invocations = (List<Invocation>) obj;
			for (Invocation invocation : invocations) {
				System.out.println("list========" + invocation.getResponse());
				ResponseFuture.received(invocation); 
			}
		} else if (obj instanceof Invocation) {
			Invocation invocation = (Invocation) obj;
			System.out.println("obj=======" + invocation.getResponse());
			ResponseFuture.received(invocation);
		}
	
	}

}
